package org.x4ut15m.xwebshell.explorer.file;

import javafx.scene.control.TreeItem;

import java.util.Objects;

public class FileTreeItem extends TreeItem<FileItem> {
    private FileItem file;

    public FileTreeItem(FileItem fileItem) {
        super(fileItem);
        file = fileItem;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof FileItem) {
            return Objects.equals(file.getFileName(), ((FileItem) obj).getFileName())
                    && Objects.equals(file.getFileType(), ((FileItem) obj).getFileType())
                    && Objects.equals(file.getAbsolutePath(), ((FileItem) obj).getAbsolutePath());
        }
        return super.equals(obj);
    }

    public FileItem getFileItem() {
        return file;
    }

    public String getFileType() {
        return file.getFileType();
    }

    public long getSize() {
        return file.getSize();
    }

    public String getFileName() {
        return file.getFileName();
    }

    public String getLastModified() {
        return file.getLastModified();
    }
}
